package com.atguigu.demojuc.chap01;

//1.继承Thread
class MyThread extends Thread{
    @Override
    public void run() {
        System.out.println("MyThread.run");
        System.out.println(Thread.currentThread().getName() + "\t" + "come-in");

    }
}

//2.实现Runnable
class MyThread1 implements Runnable {
    @Override
    public void run() {
        System.out.println("MyThread1.run");
        System.out.println(Thread.currentThread().getName() + "\t" + "come-in");
    }
}


/**
 * 创建线程方式有几种？4种
 * 1.继承Thread
 * 2.实现Runnable
 * 解决单重继承问题
 * 3.实现Callable
 * 4.线程池
 */
public class ThreadDemo {

    public static void main(String[] args) {
      /*  MyThread myThread = new MyThread();
        //myThread.run(); //只是调用了run方法，没有开启线程
        myThread.start();

        MyThread t2 = new MyThread();
        t2.start();


        MyThread1 myThread1 = new MyThread1();
        new Thread(myThread1).start();
        new Thread(myThread1).start();
*/

        new Thread(() -> System.out.println(Thread.currentThread().getName() + "\t" + "come-in")).start();
    }
}
